package cn.netjava.chapter12;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class FirstJDBC {
	
	
	public static void main(String[] args){
		try{
			String name = "root";
			
			String url = "jdbc:mysql://localhost:3306/sky";
			
			String sql = "SELECT * FROM table_1";
			
			Class.forName("com.mysql.jdbc.Driver");
		
		Connection con = DriverManager.getConnection(url,name,"123456");
		
		Statement stat = con.createStatement();
		
		ResultSet rs = stat.executeQuery(sql);
		
		while(rs.next()){
			System.out.print(rs.getString(1)+"\t");
			System.out.print(rs.getString(2)+"\t");
			System.out.print(rs.getString(3)+"\t");
			System.out.print(rs.getString(4)+"\t");
			System.out.print(rs.getString(5)+"\t");
			System.out.print(rs.getString(6)+"\t");
			System.out.println();
		}
		
		}catch(Exception ef){
			ef.printStackTrace();
		}
	}

}
